The frame
property defines the size and alignment of a view. You can specify it in one of two formats:
This format allows you to specify a fixed width and/or height for the view, as well as how it is aligned within that frame.
This format gives more control over layout by specifying minimum, maximum, and ideal dimensions for the frame. These values can be numeric or 'infinity'
, which instructs the view to expand to fill available space.
The alignment
property determines how the view is positioned within the frame. Common alignment values include:
'center'
'top'
'bottom'
'leading'
'trailing'
'topLeading'
'topTrailing'
'bottomLeading'
'bottomTrailing'
Note: Alignment only affects layout when the frame size exceeds the view’s natural size.
width
and height
format when you want precise dimensions.min
/ max
/ ideal
values when working with responsive layouts.width
/height
and minWidth
/maxWidth
, etc., in the same frame object — choose one format to avoid conflicts.The frame
property in CommonViewProps
allows fine-grained control over layout sizing and alignment, closely mirroring SwiftUI’s native frame
modifier. Use it to design clean and adaptable interfaces across different screen sizes.